﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;

public partial class Contacts : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// Action taken when click on Send button
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSend_Click(object sender, EventArgs e)
    {
        MailMessage m = new MailMessage();
        SmtpClient sc = new SmtpClient();

        try
        {
             m.From = new MailAddress(txtboxEmail.Text, txtboxName.Text);
             m.To.Add(new MailAddress("trinnse90054@fpt.edu.vn", "Joey"));

             m.Subject = txtboxName.Text + "- Customer's Opinion";
             m.IsBodyHtml = true;
             m.Body = txtboxOpinion.Text;

             sc.Host = "smtp.gmail.com";
             sc.Port = 587;
             sc.Credentials = new
             System.Net.NetworkCredential("trinnse90054@fpt.edu.vn", "nothing)#!!");
             sc.EnableSsl = true;
             sc.Send(m);

             Response.Write("Email Send successfully");
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);   
        }

    }

    /// <summary>
    /// Clear inputs when click on clear button
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnClear_Click(object sender, EventArgs e)
    {
        txtboxEmail.Text = "";
        txtboxOpinion.Text = "";
    }
}